﻿//MVVM ViewModel Locator 
//author: Alexis 2011-06-11

using System.Windows;
using TechNewsReader.ViewModel;

namespace TechNewsReader
{
    public class ViewModelLocator
    {
        /// <summary>
        /// Initializes a new instance of the MvvmViewModelLocator class.
        /// </summary>
        public ViewModelLocator()
        {

        }

        private static ViewModelLocator instance;
        public static ViewModelLocator Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = Application.Current.Resources["Locator"] as ViewModelLocator;
                }
                return instance;
            }
        }

        public static void Cleanup()
        {
            // TODO Clear the ViewModels
        }

        private MainViewModel _mainVM;
        public MainViewModel MainVM
        {
            get
            {
                return _mainVM ?? (_mainVM = new MainViewModel());
            }
        }

        private LoginWeiboViewModel _loginWeiboVM;
        public LoginWeiboViewModel LoginWeiboVM
        {
            get
            {
                return _loginWeiboVM ?? (_loginWeiboVM = new LoginWeiboViewModel());
            }
        }

        private SettingViewModel _settingVM;
        public SettingViewModel SettingVM
        {
            get
            {
                return _settingVM ?? (_settingVM = new SettingViewModel());
            }
        }
    }
}